package com.ec.rs.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.ec.common.exception.BadRequestException;
import lombok.Getter;

@Getter
public enum RequestType {
    CHECK_IN("check_in", "入住"),
    CHECK_OUT("check_out", "退住");

    @EnumValue
    private final String value;
    private final String desc;

    RequestType(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static RequestType of(String value) {
        if ("check_in".equals(value)) {
            return CHECK_IN;
        }
        if ("check_out".equals(value)) {
            return CHECK_OUT;
        }
        throw new BadRequestException("请求类型错误");
    }
}